import webspider.mysql.mysql as mysql
from webspider.settings import MYSQL_TB


def create_table():
    sql = """
            CREATE TABLE {}(
             positionName CHAR(255) NOT NULL,
             key_word CHAR(255) NOT NULL ,
             company CHAR(80) NOT NULL ,
             salary CHAR(32) NOT NULL,
             salary_min FLOAT ,
             salary_max FLOAT,
             area CHAR (72),
             location CHAR(80) NOT NULL,
             release_time CHAR(32),
             work_exp Char(32),
             edu_background CHAR(32),
             company_nature CHAR(32),
             company_scale CHAR(32),
             url CHAR(112),
             PRIMARY KEY (positionName,company,location,salary))
            """.format(MYSQL_TB)

    with mysql.DB(host='localhost', user='root', passwd='123456', db='51job') as db:
        db.execute(sql)


create_table()
